package cn.com.bsfit.netty.resp;

import cn.com.bsfit.netty.utils.StringHelper;

import java.util.HashMap;
import java.util.Map;

/**
 * 类名 BaseResponseUtils
 * 描述 公共返回数据的工具类
 *
 * @author hedonglin
 * @version 1.0
 * @date 2019/9/29 15:21
 */
public class BaseResponseUtils {
    public static Map<String, Object> successIsContains(Map<String, Object> headMap,
                                                 Map<String, Object> bodyMap,
                                                 String currTopKey,
                                                 String currHeadKey,
                                                 String currBodyKey
                                                 ){
        Map<String, Object> result = new HashMap<>();

        if (StringHelper.isNotBlank(currTopKey)){
            Map<String, Object> topMap = new HashMap<>();
            if (StringHelper.isNotBlank(currHeadKey)){
                topMap.put(currHeadKey, headMap);
            }else {
                topMap.putAll(headMap);
            }

            if (StringHelper.isNotBlank(currBodyKey)){
                topMap.put(currBodyKey, bodyMap);
            }else {
                topMap.putAll(bodyMap);
            }
            result.put(currTopKey, topMap);
        }else {
            if (StringHelper.isNotBlank(currHeadKey)){
                result.put(currHeadKey, headMap);
            }else {
                result.putAll(headMap);
            }

            if (StringHelper.isNotBlank(currBodyKey)){
                result.put(currBodyKey, bodyMap);
            }else {
                result.putAll(bodyMap);
            }
        }

        return result;
    }


    

}
